package cn.wolfcode.trip.app.controller;

import cn.wolfcode.trip.base.domain.DailyNews;
import cn.wolfcode.trip.base.query.DailyNewsQuery;
import cn.wolfcode.trip.base.service.IDailyNewsService;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 控制index页面日报部分显示的
 */
@RestController
@RequestMapping("/dailyNews")
public class DailyNewsController {
    @Autowired
    private IDailyNewsService dailyNewsService;

    @GetMapping
    public PageInfo<DailyNews> selectForCommend(DailyNewsQuery qo){
        qo.setOrderBy("createTime desc");
        if(qo.getState()==2){
            qo.setPageSize(1);
        }else if(qo.getState()==1){
            qo.setPageSize(2);
        }else if(qo.getState()==-1){
            qo.setPageSize(8);
        }
        PageInfo<DailyNews> dailyNewsPageInfo = dailyNewsService.selectForApp(qo);
        return dailyNewsPageInfo;
    }
}
